<template>
	<view>
		<uni-list>
			<uni-list-item v-for="(item,index) in options" :key="index" :title="item.key" :rightText="item.value"></uni-list-item>
		
		</uni-list>
		<button style="background-color: #440000;" type="button" class="signOut" @tap="signOut">退出</button>
	</view>
</template>

<script>
	import {toast, signOut,getStorageSync,removeStorageSync} from '../../utils/utils.js'
	import { user } from '../../api/login.js'
	export default {
		data() {
			return {
				options: [
					{
						key: '所在分组',
						value: null,
					},
					{
						key: '账号昵称',
						value: null,
					},
				]
			};
		},
		onTabItemTap() {
			const token = getStorageSync('token')||null
					
			if(!token){
				signOut()
				toast('请先登录后在使用!')
			}
		},
		onLoad(){
			this.userRequest()
		},
		methods:{
			userRequest(){
				user().then(res=>{
					if(res.code==200){
						this.options[0].value=res.roleGroup
						this.options[1].value=res.data.userName
					}else{
						this.options[0].value='分类处置组'
						this.options[1].value='离线账户'
					}
				})
			},
			signOut() {
				return signOut()
			}
		}
	}
</script>

<style lang="scss">
.signOut{
	background-color: #224c1a;
	margin: 34rpx ;
	border-radius: 50rpx;
	color: #FFFFFF;
}
</style>
